<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>电话部</title>
	<link rel="stylesheet" type="text/css" href="_ADMIN_css/css.css" />
	<script type="text/javascript" src="_ADMIN_js/jquery.min.js"></script>
	<script type="text/javascript" src="_ADMIN_js/laydate.js"></script>
	<script type="text/javascript" src="_ADMIN_layer/layer.js"></script>
</head>
<style>
     .vsAdd{
		 display: inline-block;
		 width: 70px;
		 height: 25px;
		 background-color: #2a9cdd;
		 line-height: 25px;
		 color: #fff;
		 cursor: pointer;
		 text-align: center;
	 }
	 .submit{
		 display: inline-block;
		 border: none;
		 outline: none;
		 width: 70px;
		 height: 30px;
		 background-color: #47a4e1;
		 line-height: 25px;
		 color: #fff;
		 cursor: pointer;
		 text-align: center;
	 }
	 .buttone{
		 display: inline-block;
		 padding: 1% 1.5%;
		 color: white;
		 background: #47a4e1;
		 border: none;
		 border-radius: 4px;
		 position:relative;
		 z-index: -1;
		 font-size: 14px;
	 }
	 .pagination>li{
		 float: left;
		 text-align: center;
		 border-radius: 5px;
	 }
	 .pagination>li:hover{
		 background-color: #47a4e1;
	 }
	 .pagination>li:hover>span{
		 color: white;
	 }
	 .pagination>li>a{
		 display: inline-block;
		 width: 66px;
		 line-height: 2rem;
		 border-radius: 5px;
		 border: 1px solid #CCCCCC;
	 }
	 .pagination>li>span{
		 display: inline-block;
		 width: 66px;
		 line-height: 2rem;
		 color: #47a4e1;
		 font-weight: bold;
		 font-size: 18px;
	 }
	 .pagination>li.disabled{
		 border-radius: 5px;
		 border: 1px solid #CCCCCC;
	 }
	 .pagination{
		 width:50%;
		 height: 100%;
		 margin: 0 auto;
	 }
	.option{
		margin: 10px 0;
	}
	.list{
		 margin-top: 25px;
		 width: 230px;
		 float: left;
	 }
	 .list>p{
		 margin: 5px 0;
	 }

</style>
<body>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="_ADMIN_img/coin02.png" /><span><a href="#">首页</a>&nbsp;-&nbsp;<a
					href="#">电话部</a>&nbsp;-</span>&nbsp;电话部
			</div>
		</div>

		<div class="page">
			<!-- banner页面样式 -->
			<div class="connoisseur">
				<div class="conform">
					<div class="cfD" style="float: left">
						<select id="month_select" class="bselect sssmonth" style="margin-left: 0px">
							<option value="1" id="on_month">请选择月份</option>
                            <option value="1">一月份</option>
                            <option value="2">二月份</option>
                            <option value="3">三月份</option>
                            <option value="4">四月份</option>
                            <option value="5">五月份</option>
                            <option value="6">六月份</option>
                            <option value="7">七月份</option>
                            <option value="8">八月份</option>
                            <option value="9">九月份</option>
                            <option value="10">十月份</option>
                            <option value="11">十一月份</option>
                            <option value="12">十二月份</option>
                        </select>
						</div>
						<div class="cfD" style="float: left;">
							筛选开始时间：<input autocomplete="off" class="vinput laydate-icon" name="start" type="text" id="start"/>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;筛选截止时间：
							<input autocomplete="off" class="vinput laydate-icon" name="end" type="text" id="end"/>
								&nbsp;&nbsp;&nbsp;&nbsp;
							<!--<input type="button" value="OK" class="submit">-->

						</div>
					<div style="clear: both"></div>
					<!-- 电话师统计 -->
					{foreach $res as $vo}
					<div class="list">
						<p>
							<span>　{$vo.0.user_name}当月上门量：</span><span>{$vo.0.num}</span>
						</p>
						<p>
							<span>{$vo.1.user_name}当月成交人数：</span><span>{$vo.1.num}</span>
						</p>
						<p>
							<span>{$vo.2.user_name}当月有效人数：</span><span>{$vo.2.num}</span>
						</p>
						<p>
							<span>{$vo.3.user_name}当月无效人数：</span><span>{$vo.3.num}</span>
						</p>
					</div>
					{/foreach}
					<div style="clear: both"></div>
				</div>
				<!-- banner 表格 显示 -->
				<div class="conShow">
					<div class="option cfD">
						<input type="button" value="批量分配" class="submit" onclick="batch_allot()" style="margin-right: 20px">
						<input  type="text" style="width:150px" class="vinput ssphone"  placeholder="请输入电话号码"/>
						<input type="button" value="搜索" id="sss" class="submit">
						<select class="bselect sssn" style="margin-right: 10px">
							<option value="%">请选择状态</option>
							<option value="1">已接通</option>
							<option value="0">未接通</option>
						</select>
						<input type="button" value="搜索" id="sssn" class="submit">

						<input type="button" value="查看全部" id="all" class="submit" style='margin-left:30px'>
					</div>

					<table border="1" cellspacing="0" cellpadding="0">
						<tr id="tr_head">
							<td width="50px" class="tdColor tdC"><input type="checkbox" id="allChecks" onclick="ckAll()"></td>
							<td width="55px" class="tdColor tdC">序号</td>
							<td width="80px" class="tdColor">姓名</td>
							<td width="120px" class="tdColor">联系电话</td>
							<td width="120px" class="tdColor">应聘职位</td>
							<td width="80px" class="tdColor">学历</td>
							<td width="120px" class="tdColor">专业</td>
							<td width="150px" class="tdColor">渠道来源</td>
							<td width="80px" class="tdColor">邀约人</td>
							<td width="150px" class="tdColor">预约面试时间</td>
							<td width="80px" class="tdColor">电话状态</td>
							<td width="150px" class="tdColor">录入时间</td>
							<td width="80px" class="tdColor">有效状态</td>
							<td width="80px" class="tdColor">简历</td>
							<td width="200px" class="tdColor">操作</td>
						</tr>
						<tbody id="tr_list">
						{foreach $result as $key=>$vo}
						<tr height="40px">
							<td><input type="checkbox" value="{$vo.job_id}" class="asaa"  name="check"></td>
							<td>{$key+1}</td>
							<td>{$vo.job_name}</td>
							<td>{$vo.job_phone}</td>
							<td>{:mb_substr($vo.job_work,0,6)}</td>
							<td>{$vo.job_education}</td>
							<td>{$vo.job_major}</td>
							<td>{$vo.job_source}</td>
							<td>{$vo.job_getman}</td>
							<td>{if condition="$vo.job_jointime==''"}

								{else /}
								{$vo.job_jointime|date="Y-m-d",###}
								{/if}
							</td>
							<td>{$vo.job_phone_sn}</td>
							<td>{if condition="$vo.job_createtime==''"}

								{else /}
								{$vo.job_createtime|date="Y-m-d",###}
								{/if}
							</td>
							<td>
								{if condition='$vo.job_valid_sn=="1"'}
								<a onclick="isCome(this,'{$vo.job_id}',2)" href="javascript:;" title="点击切换状态" style="color: green"  >有效</a></td>
								{else /}
								<a onclick="isCome(this,'{$vo.job_id}',1)" href="javascript:;" title="点击切换状态" style="color: #999"  href="javascript:;">无效</a>
								{/if}
							</td>
							<td>
								{if condition="$vo.job_resume_pdf==''"}
								<a class="word" href="javascript:;">
									<img src="_ADMIN_img/document-word.png" alt="简历"/>
								</a>
								{else /}<a target="_blank" href="{:url('admin/excelud/pdf_preview')}?pdf_name='{$vo.job_id}'">
								<img src="_ADMIN_img/document-word-tick.png" alt="简历"/>
								{/if}
							</a>
							</td>
							<td>
								<a class="select" onclick="detaile('{$vo.job_id}')" href="javascript:;"><button class="buttone">查看详情</button></a>
								{if condition="$vo.job_getman==''"}
								<a class="word" onclick="allot('{$vo.job_id}')" href="javascript:;"><button class="buttone">分配</button></a>
								{else /}
								<a onclick="allot(-1)" href="javascript:;"><button class="buttone">分配</button></a>
								{/if}
								<a href="{:url('admin/phone/phone_update',['job_id'=>$vo.job_id])}">
									<button class="buttone">修改</button></a>
							</td>
						</tr>
						{/foreach}
						</tbody>
					</table>
					{if condition='count($result)<=0'}
					<p style="text-align: center;color: #999;margin-top: 5px;">暂无数据...</p>
					{/if}
					<div class="paging" style="margin-top: 20px; height: 2rem;">
						{$result->render()}
					</div>
				</div>
				<!-- banner 表格 显示 end-->
			</div>
			<!-- banner页面样式end -->
		</div>

	</div>
</body>
<script type="text/javascript">
    !function(){
        laydate.skin('molv');//切换皮肤，请查看skins下面皮肤库
        laydate({elem: '#demo'});//绑定元素
    }();

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD',
        min: '1990-01-01', //设定最小日期为当前日期
        max: '2099-06-16', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD',
        min: '1990-01-01',
        max: '2099-06-16',
        istime: true,
        istoday: false,
        choose: function(datas){
            start.max = datas; //结束日选好后，充值开始日的最大日期
            time_search();
        }
    };
    laydate(start);
    laydate(end);

    //自定义日期格式
    laydate({
        elem: '#test1',
        format: 'YYYY年MM月DD日',
        festival: true, //显示节日
        choose: function(datas){ //选择日期完毕的回调
            alert('得到：'+datas);
        }
    });

    //日期范围限定在昨天到明天
    laydate({
        elem: '#hello3',
        min: laydate.now(-1), //-1代表昨天，-2代表前天，以此类推
        max: laydate.now(+1) //+1代表明天，+2代表后天，以此类推
    });
	// 查看详情
    function detaile(id){
        layer.open({
            type:2,
            title:'查看详情',
            area: ['700px', '450px'],
            fixed: false, //不固定
            maxmin: true,
            content: "{:url('admin/phone/test')}?job_id="+id,
        });
    }
    //分配
    function  allot(id){
    	if(id==-1){
    		layer.msg('不能重复分配哦！',{icon:5,time:1000});
    		return
    	}
        layer.open({
            type:2,
			title:'分配人员',
            area: ['500px', '350px'],
            fixed: false, //不固定
            maxmin: true,
            content: "{:url('admin/phone/allot')}?job_id="+id,
        });
    }
    //批量分配
	function batch_allot() {
        groups();
        var id = user_ids;
        user_ids='';
        if(id=='') {
            layer.msg("请选择!");
        }else{
            layer.open({
                type:2,
                title:'分配人员',
                area: ['500px', '350px'],
                fixed: false, //不固定
                maxmin: true,
                content: "{:url('admin/phone/allot')}?job_id="+id,
            });
		}

    }
    // 全选组 id 数组
    var user_ids='';
    function  groups(){
        $(".asaa").each(function(){
            if($(this).is(":checked")){
                user_ids+=$(this).val()+',';
            }
        });
        user_ids = user_ids.substr(0,user_ids.length-1);
    }
    //全选js事件
    function ckAll(){
        var flag=document.getElementById("allChecks").checked;
        var cks=document.getElementsByName("check");
        for(var i=0;i<cks.length;i++){
            cks[i].checked = flag;
        }
    }
    // 修改有效无效状态
    function isCome(that,id,sn) {
        var that = $(that);
        $.post("{:url('admin/phone/isCome')}",{'job_id':id,'job_get_sn':sn},function (res) {
            if(res==200){
                layer.msg('状态更改成功！',{icon:1,time:1000});
                setTimeout(function () {
                    window.location.reload();
                }, 1000);
            }
        })
    }
// 搜索调用
	$('.ssphone').on('input',function () {
        search_phone('');
    })
	$('#sss').click(function () {
        search_phone('%');
    })
    $('#sssn').click(function () {
        search_sn();
    })
	$('.sssn').change(function () {
		search_sn();
    })
 //  全部
    $('#all').click(function(){
    	window.location.href='{:url("admin/phone/all_search")}';
    })
//	筛选月份
	var m = new Date().getMonth()+1;
	$('#on_month').val(m)
	$('#month_select').change(function () {
        month_search();
    })
//	时间筛选
    function time_search() {
        var start = $('#start').val();
		var end = $('#end').val();
       	if(start!='' && end!=''){
            window.location.href='{:url("admin/phone/time_search")}?start='+start+'&end='+end;
//            $.post('{:url("admin/phone/time_search")}',{'start':start,'end':end},function (res) {
//                console.log(res);
//            },'json');
		}
    }
//	筛选方法
	function month_search() {
        var month = $('.sssmonth').val();
        window.location.href='{:url("admin/phone/month_search")}?month='+month;
//        $.post('{:url("admin/phone/month_search")}',{'month':month},function (res) {
//			console.log(res);
//        },'json');
    }
    //  时间转换
	function getYMDHMS(time){
	    if(time==''){
	        return '';
		}
		var myDate = new Date(parseInt(time)*1000);
		var YMD=myDate.getFullYear() + "-" + (myDate.getMonth()+1) + "-" + myDate.getDate();
		// var HMS=myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds();
		// var YMDHMS=YMD+" "+HMS;
		return     YMD;
	}
//	电话搜索方法
	function search_phone(flag) {
        var phone = $('.ssphone').val();
        if(phone==flag){
            layer.msg('请输入电话号码！');
        }else{
            $.post('{:url("admin/phone/search")}',{'phone':phone},function (res) {
                var res=JSON.parse(res);
                var $vo = res.data;
                var str = "";
                for(var i = 0;i < $vo.length;i++){
                    var job_jointime = getYMDHMS($vo[i].job_jointime);
                    var job_createtime = getYMDHMS($vo[i].job_createtime);
                    str += '<tr height="40px">';
                    str += '<td><input type="checkbox" value="$vo.job_id" class="asaa"  name="check"></td>';
                    str += '<td>'+(i+1)+'</td>';
                    str += '<td>'+$vo[i].job_name+'</td>';
                    str += '<td>'+$vo[i].job_phone+'</td>';
                    str += '<td>'+$vo[i].job_work+'</td>';
                    str += '<td>'+$vo[i].job_education+'</td>';
                    str += '<td>'+$vo[i].job_major+'</td>';
                    str += '<td>'+$vo[i].job_source+'</td>';
                    str += '<td>'+$vo[i].job_getman+'</td>';
                    str += '<td>'+job_jointime+'</td>';
                    str += '<td>'+$vo[i].job_phone_sn+'</td>';
                    str += '<td>'+job_jointime+'</td>';
                    if($vo[i].job_valid_sn==1){
					str+='<td><a onclick="isCome(this,'+$vo[i].job_id+',2)" href="javascript:;" title="点击切换状态" style="color: green"  >有效</a></td>'
                    }else{
                        str+='<td><a onclick="isCome(this,'+$vo[i].job_id+',1)" href="javascript:;" title="点击切换状态" style="color: #999"  >有效</a></td>'
					}
                    str += '<td><a target="_blank" href="{:url(\'admin/excelud/word_preview\')}?word_name='+$vo[i].job_resume+'"><img src="_ADMIN_img/document-word-tick.png" alt="简历"/></a></td>';
                    str += '<td><a class="select" onclick="detaile('+$vo[i].job_id+')" href="javascript:;"><button class="buttone">查看详情</button></a> <a class="word" onclick="allot('+$vo[i].job_id+')" href="javascript:;"><button class="buttone">分配</button></a> <a href="{:url(\'admin/phone/phone_update\')}?job_id="'+$vo[i].job_id+'> <button class="buttone">修改</button></a> </td>';
                    str += '</tr>';
                }
                $('#tr_list').html(str);
                $('.paging').html('');
            },'json');
        }
    }
//    状态搜索方法
    function search_sn() {
        var sn = $('.sssn').val();
		$.post('{:url("admin/phone/search_sn")}',{'sn':sn},function (res) {
			var res=JSON.parse(res);
			var $vo = res.data;
			var str = "";
			for(var i = 0;i < $vo.length;i++){
                var job_jointime = getYMDHMS($vo[i].job_jointime);
                var job_createtime = getYMDHMS($vo[i].job_createtime);
				str += '<tr height="40px">';
				str += '<td><input type="checkbox" value="$vo.job_id" class="asaa"  name="check"></td>';
				str += '<td>'+(i+1)+'</td>';
				str += '<td>'+$vo[i].job_name+'</td>';
				str += '<td>'+$vo[i].job_phone+'</td>';
				str += '<td>'+$vo[i].job_work+'</td>';
				str += '<td>'+$vo[i].job_education+'</td>';
				str += '<td>'+$vo[i].job_major+'</td>';
				str += '<td>'+$vo[i].job_source+'</td>';
				str += '<td>'+$vo[i].job_getman+'</td>';
				str += '<td>'+job_jointime+'</td>';
				str += '<td>'+$vo[i].job_phone_sn+'</td>';
				str += '<td>'+job_createtime+'</td>';
                if($vo[i].job_valid_sn==1){
                    str+='<td><a onclick="isCome(this,'+$vo[i].job_id+',2)" href="javascript:;" title="点击切换状态" style="color: green"  >有效</a></td>';
                }else{
                    str+='<td><a onclick="isCome(this,'+$vo[i].job_id+',1)" href="javascript:;" title="点击切换状态" style="color: #999"  >有效</a></td>';
                }
				str += '<td><a target="_blank" href="{:url(\'admin/excelud/word_preview\')}?word_name='+$vo[i].job_resume+'"><img src="_ADMIN_img/document-word-tick.png" alt="简历"/></a></td>';
				str += '<td><a class="select" onclick="detaile('+$vo[i].job_id+')" href="javascript:;"><button class="buttone">查看详情</button></a> <a class="word" onclick="allot('+$vo[i].job_id+')" href="javascript:;"><button class="buttone">分配</button></a> <a href="{:url(\'admin/phone/phone_update\')}?job_id="'+$vo[i].job_id+'> <button class="buttone">修改</button></a> </td>';
				str += '</tr>';
			}
			$('#tr_list').html(str);
			$('.paging').html('');
		},'json');
    }
</script>
</html>